<!-- 医保信息维护员布局组件 -->
<template>
  <div class="medical-info-layout">
    <div class="layout-header">
      <div class="header-left">
        <h2>医疗保险基本信息维护系统</h2>
      </div>
      <div class="header-right">
        <el-dropdown @command="handleCommand">
          <span class="user-info">
            <el-icon><User /></el-icon>
            {{ userInfo.username }}
            <el-icon><ArrowDown /></el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item command="profile">个人信息</el-dropdown-item>
              <el-dropdown-item command="logout" divided>退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
    
    <div class="layout-container">
      <div class="layout-sidebar">
        <el-menu
          :default-active="$route.path"
          class="sidebar-menu"
          router
          :collapse="isCollapse"
        >
          <el-menu-item index="/medical-info/drugs">
            <el-icon><Medicine /></el-icon>
            <template #title>医保药品数据维护</template>
          </el-menu-item>
          <el-menu-item index="/medical-info/treatment">
            <el-icon><FirstAidKit /></el-icon>
            <template #title>诊疗项目数据维护</template>
          </el-menu-item>
          <el-menu-item index="/medical-info/facilities">
            <el-icon><OfficeBuilding /></el-icon>
            <template #title>医疗服务设施维护</template>
          </el-menu-item>
          <el-menu-item index="/medical-info/drug-ratio">
            <el-icon><PieChart /></el-icon>
            <template #title>药品报销比例维护</template>
          </el-menu-item>
          <el-sub-menu index="/medical-info/hospital-ratio">
            <template #title>
              <el-icon><DataLine /></el-icon>
              <span>医院报销比例维护</span>
            </template>
            <el-menu-item index="/medical-info/hospital-ratio-3">三级医院</el-menu-item>
            <el-menu-item index="/medical-info/hospital-ratio-2">二级医院</el-menu-item>
            <el-menu-item index="/medical-info/hospital-ratio-1">一级医院</el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="/system">
            <template #title>
              <el-icon><Setting /></el-icon>
              <span>系统管理</span>
            </template>
            <el-menu-item index="/system/user">用户管理</el-menu-item>
            <el-menu-item index="/system/role">角色管理</el-menu-item>
            <el-menu-item index="/system/menu">菜单管理</el-menu-item>
          </el-sub-menu>
        </el-menu>
      </div>
      
      <div class="layout-main">
        <router-view />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'
import { User, ArrowDown, Medicine, FirstAidKit, OfficeBuilding, PieChart, DataLine, Setting } from '@element-plus/icons-vue'

const router = useRouter()
const isCollapse = ref(false)

const userInfo = reactive({
  username: localStorage.getItem('username') || '用户'
})

const handleCommand = (command) => {
  if (command === 'logout') {
    localStorage.clear()
    router.push('/login')
  } else if (command === 'profile') {
    // 打开个人信息页面
  }
}
</script>

<style scoped>
.medical-info-layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.layout-header {
  height: 60px;
  background: #409eff;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-left h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
}

.user-info {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.layout-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.layout-sidebar {
  width: 250px;
  background: #fff;
  border-right: 1px solid #e4e7ed;
  overflow-y: auto;
}

.sidebar-menu {
  border-right: none;
  height: 100%;
}

.layout-main {
  flex: 1;
  overflow-y: auto;
  background: #f5f5f5;
}
</style>
